//
//  MyReleaseServiceCell.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/12/11.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "MyReleaseServiceCell.h"
#import "ServiceModel.h"
@interface MyReleaseServiceCell()
@property (weak, nonatomic) IBOutlet UIButton *deleBtn;
@property (weak, nonatomic) IBOutlet UIView *view;
@property (weak, nonatomic) IBOutlet UIImageView *iv;
@property (weak, nonatomic) IBOutlet UILabel *titleL;
@property (weak, nonatomic) IBOutlet UILabel *resourceL;
@end
static NSString *identifier = @"MyReleaseServiceCell";
@implementation MyReleaseServiceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.view.layer.cornerRadius = 3;
    self.view.layer.borderColor = kLineColor.CGColor;
    self.view.layer.borderWidth = 1;
    self.iv.layer.borderColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1].CGColor;
    self.iv.layer.borderWidth = 1;
    self.iv.layer.cornerRadius = 6;
    self.iv.layer.masksToBounds = YES;
    self.iv.layer.borderColor = k187Color.CGColor;
    self.deleBtn.layer.masksToBounds = YES;
    self.deleBtn.layer.cornerRadius = 3;
    self.editingBtn.layer.masksToBounds = YES;
    self.editingBtn.layer.cornerRadius = 3;
}
+(instancetype)cellNibWithTableView:(UITableView *)tableView
{
    MyReleaseServiceCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        [tableView registerNib:[UINib nibWithNibName:@"MyReleaseServiceCell" bundle:nil] forCellReuseIdentifier:identifier];
        cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setServiceModel:(ServiceModel *)serviceModel
{
    _serviceModel = serviceModel;
    [self.iv sd_setImageWithURL:[NSURL URLWithString:serviceModel.logo] placeholderImage:[UIImage imageNamed:@"headImg"]];
//    self.titleL.text = [NSString stringWithFormat:@"%@|%@|%@",serviceModel.associationtype.length?serviceModel.associationtype:@"",serviceModel.associationtypesub1.length?serviceModel.associationtypesub1:@"",serviceModel.industryList.count?serviceModel.industryList[0]:@""];
    self.titleL.text = [NSString stringWithFormat:@"%@%@%@",serviceModel.associationtype.length?serviceModel.associationtype:@"",serviceModel.typeSub1List.count?[NSString stringWithFormat:@"|%@",serviceModel.typeSub1List[0]]:@"",serviceModel.typeSub1List.count>1?[NSString stringWithFormat:@"|%@",serviceModel.typeSub1List[1]]:@""];
    self.resourceL.text = [NSString stringWithFormat:@"服务概述:%@",serviceModel.resource.length?serviceModel.resource:@""];
}
- (void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
}
- (IBAction)editingBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(myReleaseServiceCell:withClickBtn:withIndexPath:withHomeModel:)]) {
        [self.delegate myReleaseServiceCell:self withClickBtn:sender withIndexPath:self.indexPath withHomeModel:self.serviceModel];
    }
}
- (IBAction)deleBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(myReleaseServiceCell:withClickBtn:withIndexPath:withHomeModel:)]) {
        [self.delegate myReleaseServiceCell:self withClickBtn:sender withIndexPath:self.indexPath withHomeModel:self.serviceModel];
    }
}

@end
